Skip to content

feat: add uniqueValue optimization for notEq/notIn in InclusiveMetricsEvaluator#754

Merged
wgtmac merged 2 commits into
apache:mainfrom
WZhuo:unique_value
Jun 18, 2026
Merged

feat: add uniqueValue optimization for notEq/notIn in InclusiveMetricsEvaluator#754
wgtmac merged 2 commits into
apache:mainfrom
WZhuo:unique_value

Conversation

@WZhuo

@WZhuo WZhuo commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

When a column has a single unique value (no nulls, no NaNs, and lower bound == upper bound), notEq(X) and notIn({...X...}) can prune files where that unique value matches the predicate, returning ROWS_CANNOT_MATCH. Previously these always returned ROWS_MIGHT_MATCH, never pruning.

This mirrors the upstream Java InclusiveMetricsEvaluator.uniqueValue() logic. The StrictMetricsEvaluator is unchanged: its existing bounds-based notEq/notIn logic already covers the single-value case, matching upstream Java which has no uniqueValue helper there.

Ports the corresponding testNotEqWithSingleValue/testNotInWithSingleValue cases from the Java test suite.

…sEvaluator

When a column has a single unique value (no nulls, no NaNs, and lower
bound == upper bound), notEq(X) and notIn({...X...}) can prune files
where that unique value matches the predicate, returning ROWS_CANNOT_MATCH.
Previously these always returned ROWS_MIGHT_MATCH, never pruning.

This mirrors the upstream Java InclusiveMetricsEvaluator.uniqueValue()
logic. The StrictMetricsEvaluator is unchanged: its existing bounds-based
notEq/notIn logic already covers the single-value case, matching upstream
Java which has no uniqueValue helper there.

Ports the corresponding testNotEqWithSingleValue/testNotInWithSingleValue
cases from the Java test suite.

@zhjwpku zhjwpku left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked the java's impl, LGTM

Comment thread src/iceberg/expression/inclusive_metrics_evaluator.cc Outdated
Co-authored-by: Junwang Zhao <zhjwpku@gmail.com>
@wgtmac wgtmac merged commit 6f50a39 into apache:main Jun 18, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants